﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Coherence.Linq;
using System.Linq.Expressions;
using Tangosol.Util.Extractor;

namespace Coherence.Contrib
{
    internal class MetadataFilterBuilder : FilterBuilder
    {

        protected override Expression VisitMemberAccess(MemberExpression m)
        {
            //return base.VisitMemberAccess(m);

            if (m.Expression != null && m.Expression.NodeType == ExpressionType.Parameter)
            {
                globalFilter = new ReflectionExtractor("getProperty", new object[] { m.Member.Name });
                return m;
            }
            throw new NotSupportedException(string.Format("The member '{0}' is not supported", m.Member.Name));
        }

    }
}
